// 文件类型映射表
const mimeTypeMap = {
  png: 'image/png',
  jpg: 'image/jpeg',
  jpeg: 'image/jpeg',
  mp4: 'video/mp4',
  pdf: 'application/pdf',
  xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  xls: 'application/vnd.ms-excel',
  ppt: 'application/vnd.ms-powerpoint',
  pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  doc: 'application/msword'
};

/**
 * 根据文件扩展名获取MIME类型
 * @param {string} fileName - 文件名或者带有扩展名的字符串
 * @returns {string} 对应的MIME类型
 */
export const getMimeType = (fileName: string): string => {
  // 获取文件扩展名并转换为小写
  const extension = fileName.split('.').pop()?.toLowerCase();

  // 根据扩展名查找MIME类型
  return extension && mimeTypeMap[extension] ? mimeTypeMap[extension] : 'application/octet-stream';
};